package com.zzyl.job;

import com.xxl.job.core.handler.annotation.XxlJob;
import com.zzyl.mapper.DeviceDataMapper;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalDateTime;


@Component
@Log
public class DeviceDataClearJob {

    @Autowired
    private DeviceDataMapper deviceDataMapper;


    @XxlJob("clearDeviceDataJob")
    public void clearDeviceDataJob() {
        log.info("设备上报数据,定时清理开始....");
        // 每天凌晨1点清理7天之前的数据（包含正常的数据，以及已经处理的异常数据）
        LocalDateTime date = LocalDateTime.now().minusDays(7);
        deviceDataMapper.clearDeviceDataJob(date);
        log.info("设备上报数据,定时清理结束....");
    }
}
